package com.liufh;

import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author: liufh
 * @create: 2021-12-30 16:22
 */
public class DubboProviderMain {

    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
        context.start();
        System.out.println("服务提供者启动成功...");
        System.in.read();
    }

    /**
     * 说明：
     * 注解方式，@EnableDubbo、@Service、@Reference组件扫描 用的都是dubbo的
     * 通过@EnableDubbo完成dubbo配置，使用dubbo功能
     */
    @Configuration
    @PropertySource("classpath:/dubbo-provider.properties")
    @EnableDubbo(scanBasePackages = "com.liufh.service.impl")
    static class ProviderConfiguration {
//        @Bean
//        public RegistryConfig registryConfig() {
//            RegistryConfig registryConfig = new RegistryConfig();
//            registryConfig.setAddress("zookeeper://127.0.0.1:2181");// 可直接在配置文件中配置（参考consumer）
//            return registryConfig;
//        }
    }

}
